/*
* blog.h - This file is the part of the wp-notifier.(code name "luan luan")
* Copyright (C) 2010 Dean Lee <deanlee3@gmail.com>, http://www.deanlee.cn
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
* 
* Acknowledgements:
*   <> Many thanks to all of you, who have encouraged me to update my articles
*     and code, and who sent in bug reports and fixes.
* 
*/
#ifndef _BLOG_H
#define _BLOG_H
#include <QString>
#include <QDomElement>
#include <QDateTime>
class CommentsModel;
class BlogData : public QSharedData
{
public:
	BlogData();
	BlogData(const BlogData& other);
	void fromXml(const QDomElement& el);
	void toXml(QDomElement& el) const;
	QString m_url;
	int m_blog_id;
	QString m_blog_name;
	QString m_username;
	QString m_password;
	QString m_xmlrpc_url;
	bool m_is_admin;

};

class Blog
{
public:
	Blog();
	Blog(const Blog& other);
	~Blog();
	QString url()const{return d->m_url;}
	int id() const{return d->m_blog_id;}
	QString name()const{return d->m_blog_name;}
	QString userName()const{return d->m_username;}
	QString password()const{return d->m_password;}
	QString xmlrpcUrl()const{return d->m_xmlrpc_url;}
	bool isAdmin()const{return d->m_is_admin;}
	void setUrl(const QString& url){d->m_url = url;}
	void setId(int id){d->m_blog_id = id;}
	void setName(const QString& name){d->m_blog_name = name;}
	void setUserName(const QString& userName){d->m_username = userName;}
	void setPassword(const QString& password){d->m_password = password;}
	void setXmlrpcUrl(const QString& url){d->m_xmlrpc_url = url;}
	void setIsAdmin(bool admin){d->m_is_admin = admin;}
	void fromXml(const QDomElement& el){d->fromXml(el);};
	void toXml(QDomElement& el)const{d->toXml(el);};
private:
     QSharedDataPointer<BlogData> d;
};

//class Blog : public BlogData
//{
//
//public:
//	Blog();
//	~Blog();
//	void fromXml(const QDomElement& el);
//	QDomElement toXml(QDomDocument *doc)const;
//	Blog& operator=(const Blog& other);
//	//void setCount(CommentData::CommentStatus s, int value);
//public:
//	// comment state
//	int m_commentCount[3];
//	/*int m_nApprove;
//	int m_nSpam;
//	int m_nHold;*/
//	QDateTime m_lastTimeStamp;
//	int m_nLastId;
//	CommentsModel* m_model;
//	//QList<Comment> m_comments;
//	//protected slots:
//	//	void getCommentsFinished(bool);
//	//	void xmlRpcFinished(bool);
//};

#endif